from selenium import webdriver
import time

# driver = webdriver.Edge()
driver = webdriver.Chrome()
# driver = webdriver.Firefox()
driver.maximize_window()
driver.get('https://www.baidu.com/')
time.sleep(10)

import pymysql

from bs4 import BeautifulSoup


class db():
    def __init__(self, user, password, database):
        self.con = pymysql.connect(user=user, password=password, database=database)
        self.cur = self.con.cursor()

    def seatch(self, sql):
        self.cur.execute(sql)
        return self.cur.fetchall()

    def insert(self, name):
        # self.cur.execute("insert into dy (name) values (%s)", (name,))
        self.cur.execute("insert into dy (name) values ('%s')" % name)
        self.con.commit()

    def close(self):
        self.cur.close()
        self.con.close()


# class Day16(unittest.TestCase):
#     def setuo(self):
#         headers = {'User_agent': 'M'}
#         response = requests.get('https://movie.douban.com/250', headers=headers)
#         response.enconding = 'utf-8'
#         soup = BeautifulSoup(response.text, 'html.parser')
#         movie_list = soup.find_all('div', class_='title')[:10]
#         for movie in movie_list:
#             name = movie.select_one('.title').text.strip()
#             self.mydb.instart(name)
#             print(已存入电影：{name})


import csv

class read_csv():

    def read_csv(self, filepath):
        with open(filepath, 'r') as f:
            datas = csv.reader(f)
            lis = []
            for item in datas:
                lis.append(item)
            lis.pop(0)
            return lis

from openpyxl import load_workbook
class read_excel():

    def __init__(self, filepath, sheetname):
        self.filepath = load_workbook(filepath)
        self.sheetname = self.filepath[sheetname]

    def getdata(self):
        for item in self.sheetname:
            list = []
            list.append(item[0].value)
            list.append(item[1].value)













